#!/usr/bin/python
# -*- coding:utf-8 -*-
import configparser
from cn.sys.home.utils.SystemUtils import SystemProperties
class ReadConfig:

    def __init__(self,cf):
        self.driverClass = cf.get("db", "driverClass")
        self.jdbcUrl = cf.get("db", "jdbcUrl")
        self.user = cf.get("db", "user")
        self.password = cf.get("db", "password")
        self.host = cf.get("db", "host")
        self.charset = cf.get("db", "charset")
        self.cursorclass = cf.get("db", "cursorclass")
        self.db = cf.get("db", "database")

    @staticmethod
    def readConfigByPath(path):
        cf = configparser.ConfigParser()
        _path = SystemProperties.getWebRoot()+path
        cf.read(_path)
        return ReadConfig(cf)


    @staticmethod
    def readDBScriptByPath(path):
        _path = SystemProperties.getWebRoot() + path
        fo = open(_path, "r+")
        return fo.read()


if __name__=='__main__':
    dbCondif = ReadConfig.readConfigByPath("/cn/sys/home/conf/db.ini")
    print( dbCondif.password)